import 'package:app/core/rtc/base/session_type.dart';
import 'package:app/routes/my_routes.dart';
import 'package:get/get.dart';

import 'state.dart';

class ChatLogic extends GetxController {
  final state = ChatState();

  call(String callName, String sessionType, String callPhone,
      {bool isShareScreen = false}) {
    state.callPeerID.value = callPhone;
    switch (sessionType) {
      case SessionType.AUDIO:
        callAudio(callPhone, callName);
        break;
      default:
        callVideo(callPhone, callName, isShareScreen);
        break;
    }
    // this.update();
  }

  callAudio(String callPhone, callName) {
    Get.toNamed(RouteConfig.RTC, arguments: {
      "phone": callPhone,
      "name": callName,
      "type": SessionType.AUDIO,
      "isCaller": true
    });
  }

  callVideo(String callPhone, callName, bool screenShare) {
    Get.toNamed(RouteConfig.RTC, arguments: {
      "phone": callPhone,
      "name": callName,
      "type": screenShare ? SessionType.SCREEN : SessionType.VIDEO,
      "isCaller": true
    });
  }
}
